package com.dyh.quickdemozwei.shiyanchang.pipeLine;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;

import java.util.Map;
import java.util.function.Function;

@Slf4j
public class SpringBeanRegister implements ApplicationListener<ApplicationReadyEvent> {


    @Autowired
    PipeLineBaseExecutor pipeLineBaseExecutor;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        ApplicationContext applicationContext = event.getApplicationContext();
        Map<String,Function> functionMap = applicationContext.getBeansOfType(Function.class);
//        for (Map.Entry<String, Function> entry : functionMap.entrySet()) {
//            log.info("{} {}",entry.getKey(),entry.getValue());
//        }

        pipeLineBaseExecutor.setSpringBeanMap(functionMap);
    }
}
